<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">需求单号</label>
        <el-input v-model="query.docNo" clearable placeholder="需求单号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">申请行号</label>
        <el-input v-model="query.docItem" clearable placeholder="申请行号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">发料厂别</label>
        <el-input v-model="query.plantFrom" clearable placeholder="发料厂别" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">工单号</label>
        <el-input v-model="query.woNo" clearable placeholder="工单号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">线体</label>
        <el-input v-model="query.lineId" clearable placeholder="线体" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">线体描述</label>
        <el-input v-model="query.lineName" clearable placeholder="线体描述" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">站位/工位</label>
        <el-input v-model="query.track" clearable placeholder="站位/工位" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">发料仓码</label>
        <el-input v-model="query.slocFrom" clearable placeholder="发料仓码" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">成品料号</label>
        <el-input v-model="query.mat" clearable placeholder="成品料号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">成品料号描述</label>
        <el-input v-model="query.matName" clearable placeholder="成品料号描述" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">料号</label>
        <el-input v-model="query.material" clearable placeholder="料号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">料号名称</label>
        <el-input v-model="query.materialName" clearable placeholder="料号名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="需求单号" prop="docNo">
            <el-input v-model="form.docNo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="申请行号" prop="docItem">
            <el-input v-model="form.docItem" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="发料厂别">
            <el-input v-model="form.plantFrom" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="工单号">
            <el-input v-model="form.woNo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="线体" prop="lineId">
            <el-input v-model="form.lineId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="线体描述">
            <el-input v-model="form.lineName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="站位/工位" prop="track">
            <el-input v-model="form.track" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="发料仓码" prop="slocFrom">
            <el-input v-model="form.slocFrom" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="成品料号">
            <el-input v-model="form.mat" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="成品料号描述">
            <el-input v-model="form.matName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="料号" prop="material">
            <el-input v-model="form.material" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="料号名称">
            <el-input v-model="form.materialName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="单位">
            <el-input v-model="form.unit" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="需求数量" prop="requestQty">
            <el-input v-model="form.requestQty" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="收料厂别">
            <el-input v-model="form.plantTo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="合并单据群组号">
            <el-input v-model="form.docGroupNo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="备料单号" prop="sPickNo">
            <el-input v-model="form.sPickNo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="收料仓码">
            <el-input v-model="form.slocTo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="备料单单位用量">
            <el-input v-model="form.bomRate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="预计总盘数">
            <el-input v-model="form.palletQty" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="需求套数">
            <el-input v-model="form.sets" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="领料单物料总应发量" prop="totalQty">
            <el-input v-model="form.totalQty" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="工单物料总应发量" prop="totalQtyTtl">
            <el-input v-model="form.totalQtyTtl" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="供应商" prop="vendor">
            <el-input v-model="form.vendor" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="工单物料剩余待发量">
            <el-input v-model="form.remainQty" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="工单计划线体物料剩余待发量">
            <el-input v-model="form.planRemainQty" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="排产日 YYYYMMDD">
            <el-input v-model="form.classdate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="计划时间 YYYYMMDDHH24MISS">
            <el-input v-model="form.schTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否插单需求 (Y/N)">
            <el-input v-model="form.isInsertDoc" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建时间" prop="createTime">
            <el-input v-model="form.createTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新时间" prop="updateTime">
            <el-input v-model="form.updateTime" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="id" label="自增主键" />
        <el-table-column prop="docNo" label="需求单号" />
        <el-table-column prop="docItem" label="申请行号" />
        <el-table-column prop="plantFrom" label="发料厂别" />
        <el-table-column prop="woNo" label="工单号" />
        <el-table-column prop="lineId" label="线体" />
        <el-table-column prop="lineName" label="线体描述" />
        <el-table-column prop="track" label="站位/工位" />
        <el-table-column prop="slocFrom" label="发料仓码" />
        <el-table-column prop="mat" label="成品料号" />
        <el-table-column prop="matName" label="成品料号描述" />
        <el-table-column prop="material" label="料号" />
        <el-table-column prop="materialName" label="料号名称" />
        <el-table-column prop="unit" label="单位" />
        <el-table-column prop="requestQty" label="需求数量" />
        <el-table-column prop="plantTo" label="收料厂别" />
        <el-table-column prop="docGroupNo" label="合并单据群组号" />
        <el-table-column prop="sPickNo" label="备料单号" />
        <el-table-column prop="slocTo" label="收料仓码" />
        <el-table-column prop="bomRate" label="备料单单位用量" />
        <el-table-column prop="palletQty" label="预计总盘数" />
        <el-table-column prop="sets" label="需求套数" />
        <el-table-column prop="totalQty" label="领料单物料总应发量" />
        <el-table-column prop="totalQtyTtl" label="工单物料总应发量" />
        <el-table-column prop="vendor" label="供应商" />
        <el-table-column prop="remainQty" label="工单物料剩余待发量" />
        <el-table-column prop="planRemainQty" label="工单计划线体物料剩余待发量" />
        <el-table-column prop="classdate" label="排产日 YYYYMMDD" />
        <el-table-column prop="schTime" label="计划时间 YYYYMMDDHH24MISS" />
        <el-table-column prop="isInsertDoc" label="是否插单需求 (Y/N)" />
        <el-table-column prop="createTime" label="创建时间" />
        <el-table-column prop="updateTime" label="更新时间" />
        <!-- <el-table-column v-if="checkPer(['admin','dcsOrderDemandItem:edit','dcsOrderDemandItem:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column> -->
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudDcsOrderDemandItem from '@/api/work/dcsOrderDetail'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
// import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { docNo: null, docItem: null, plantFrom: null, woNo: null, lineId: null, lineName: null, track: null, slocFrom: null, mat: null, matName: null, material: null, materialName: null, unit: null, requestQty: null, plantTo: null, docGroupNo: null, sPickNo: null, slocTo: null, bomRate: null, palletQty: null, sets: null, totalQty: null, totalQtyTtl: null, vendor: null, remainQty: null, planRemainQty: null, classdate: null, schTime: null, isInsertDoc: null, createTime: null, updateTime: null }
export default {
  name: 'DcsOrderDetail',
  components: { pagination, crudOperation, rrOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: 'dcs_order_demand_item', url: 'api/dcsOrderDemandItem', idField: 'id', sort: 'id,desc', crudMethod: { ...crudDcsOrderDemandItem },
      optShow: {
        add: false,
        edit: false,
        download: true,
        reset: true,
        del: false
      }
    })
  },
  data() {
    return {
      permission: {
        add: ['admin', 'dcsOrderDemandItem:add'],
        edit: ['admin', 'dcsOrderDemandItem:edit'],
        del: ['admin', 'dcsOrderDemandItem:del']
      },
      rules: {
        docNo: [
          { required: true, message: '需求单号不能为空', trigger: 'blur' }
        ],
        docItem: [
          { required: true, message: '申请行号不能为空', trigger: 'blur' }
        ],
        lineId: [
          { required: true, message: '线体不能为空', trigger: 'blur' }
        ],
        track: [
          { required: true, message: '站位/工位不能为空', trigger: 'blur' }
        ],
        slocFrom: [
          { required: true, message: '发料仓码不能为空', trigger: 'blur' }
        ],
        material: [
          { required: true, message: '料号不能为空', trigger: 'blur' }
        ],
        requestQty: [
          { required: true, message: '需求数量不能为空', trigger: 'blur' }
        ],
        sPickNo: [
          { required: true, message: '备料单号不能为空', trigger: 'blur' }
        ],
        totalQty: [
          { required: true, message: '领料单物料总应发量不能为空', trigger: 'blur' }
        ],
        totalQtyTtl: [
          { required: true, message: '工单物料总应发量不能为空', trigger: 'blur' }
        ],
        vendor: [
          { required: true, message: '供应商不能为空', trigger: 'blur' }
        ],
        createTime: [
          { required: true, message: '创建时间不能为空', trigger: 'blur' }
        ],
        updateTime: [
          { required: true, message: '更新时间不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
        { key: 'docNo', display_name: '需求单号' },
        { key: 'docItem', display_name: '申请行号' },
        { key: 'plantFrom', display_name: '发料厂别' },
        { key: 'woNo', display_name: '工单号' },
        { key: 'lineId', display_name: '线体' },
        { key: 'lineName', display_name: '线体描述' },
        { key: 'track', display_name: '站位/工位' },
        { key: 'slocFrom', display_name: '发料仓码' },
        { key: 'mat', display_name: '成品料号' },
        { key: 'matName', display_name: '成品料号描述' },
        { key: 'material', display_name: '料号' },
        { key: 'materialName', display_name: '料号名称' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      // this.$router.push(`/dcsManagement/dcsOrderDetail?docNo=${item.docNo}`)
      this.query.docNo = this.$route.query.docNo
      return true
    }
  }
}
</script>

<style scoped>

</style>
